/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package oop.demo.restaurantmanagementsystem;

import java.util.ArrayList;

/**
 * Abstract class that provides structure 
 * for the billing system
 * @author ashongtical
 */

public abstract class RestaurantBillingSystem {
    
    
   //Constructor to initialize the menu
    ArrayList<Meal> menu;
    

    
    public RestaurantBillingSystem(){
        menu = new ArrayList<>();
    }
   
    //Add a meal to the menu
    //meal: The meal to add
    public void addMeal(Meal meal){
        this.menu.add(meal);
        System.out.println("added'" + meal.getName() + "'to the menu");
    }
   
    
    
    
    //Remove a meal from the menu by name
    //mealName The name of the meal to remove
    //return true if meal was removed, false otherwise
    public  boolean removeMeal(String mealName){
        for (Meal meal : menu){
            if (meal.getName().equals(mealName)){
                menu.remove(meal);
                System.out.println("removed'" + mealName + "'from the menu");
                return true;
            }
        }
        return false;
    }
    
    //Display all meals on the menu
    public void displayMenu(){
        if(menu.isEmpty()){
            System.out.println("The menu is empty");
        }else{
            for(Meal meal: menu){
                System.out.println(meal);
            }
            
        }
        
    }
    
    
    //Find a meal on the menu by name
    //mealName: The name of the meal to find
    //The meal if found, null otherwise
    public Meal findMealByName(String mealName){
        for (Meal meal: menu){
            if (meal.getName().equals(mealName)){
                return meal;
            }   
        }
        System.out.println("meal" + mealName + "is not found on the menu");
        return null;
    }
    
    
    
    
    //Abstract method for adding a meal to an order
    //mealName The name of the meal to add to the order
    // return boolean indicating success or failure
    public abstract boolean addMealToOrder(String mealName);
    
    
    
    
    //Abstract method for calculating the bill
    //return The total bill amount
    public abstract double calculatingBill();
    
}
